package com.project.internship.controller.info;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.project.internship.entity.resp.RespPageBean;
import com.project.internship.service.BasesService;
import com.project.internship.vo.BasesDeptVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/information/base")
public class InfoBaseController {

    @Autowired
    BasesService basesService;

    /**
     * 学校端根据公司名字进行查询
     * 带关键字的分页查询
     * @param current  当前页
     * @param size     每页的数据大小
     * @param keyword  关键字
     * @return
     */
    @GetMapping("/")
    public RespPageBean getAllBases(@RequestParam(defaultValue = "1") Integer current,
                                    @RequestParam(defaultValue = "10") Integer size,
                                    String keyword){
        Page<BasesDeptVO> page = new Page<>(current,size);

        Long total = basesService.getAllBases(page,keyword).getTotal();
        List<BasesDeptVO> data =  basesService.getAllBases(page,keyword).getRecords();

        return new RespPageBean(total,data);
    }


}
